package cn.xopencode.userservice.rpc;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.userservice.manager.UserManager;
import cn.xopencode.userservice.rpc.user.UserRpc;
import cn.xopencode.userservice.rpc.user.dto.*;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService(version = "${dubbo.provider.UserRpc.version}", validation = "false")
public class UserRpcImpl implements UserRpc {

    @Autowired
    private UserManager userManager;

    @Override
    public CommonResult<UserDTO> getUser(String userId) {
        return CommonResult.success(userManager.getUser(userId));
    }

    @Override
    public CommonResult<List<UserDTO>> getUserList(String userId) {
        return CommonResult.success(userManager.getUserList(userId));
    }

    @Override
    public CommonResult<List<UserDTO>> getUserList(UserParamDTO userParamDTO) {
        return CommonResult.success(userManager.getUserList(userParamDTO));
    }

    @Override
    public String getEmployeeName(String userIds) {
        return userManager.getEmployeeName(userIds);
    }

    @Override
    public CommonResult<String> createUser(CreateUserDTO createUserDTO) {
        return CommonResult.success(userManager.CreateUser(createUserDTO));
    }

    @Override
    public CommonResult<PageResult<UserDTO>> findUserList(UserPageDTO userPageDTO) {
        return CommonResult.success(userManager.findUserList(userPageDTO));
    }

    @Override
    public CommonResult<Integer> updateProperty(List<UpdatePropertyDTO> updatePropertyDTOList) {
        return CommonResult.success(userManager.updateProperty(updatePropertyDTOList));
    }

    @Override
    public CommonResult<Integer> updateUser(List<UpdateUserDTO> updateUserDTOList) {
        return CommonResult.success(userManager.updateUser(updateUserDTOList));
    }

    @Override
    public CommonResult<UserDTO> createUserIfAbsent(CreateUserDTO createUserDTO) {
        return CommonResult.success(userManager.createUserIfAbsent(createUserDTO));
    }
}
